#include "asm.h"
#include "regdef.h"
#include "inst_test.h"

LEAF(n14_ld_w_test)
    
    addi.w s0, s0 ,1
    li  s2, 0x0
###test inst
    TEST_LD_W(0xc822c7e8, 0xd34c0,  0x6a8,  0x6a8, 0xc822c7e8)
    TEST_LD_W(0x71737c10, 0xdf660,  0x0e4,  0x0e4, 0x71737c10)
    TEST_LD_W(0x03682420, 0xd24e4,  0x180,  0x180, 0x03682420)
    TEST_LD_W(0x6f59f5d3, 0xdabdc,  0x0b0,  0x0b0, 0x6f59f5d3)
    TEST_LD_W(0x56d90696, 0xd28b4,  0x1f4,  0x1f4, 0x56d90696)
    TEST_LD_W(0xeda52048, 0xd4ea8,  0x2b0,  0x2b0, 0xeda52048)
    TEST_LD_W(0x383e8970, 0xd8ae4,  0x688,  0x688, 0x383e8970)
    TEST_LD_W(0x28c90aca, 0xd3840, -0x4a8, -0x4a8, 0x28c90aca)
    TEST_LD_W(0x54aca118, 0xd06c0, -0x51c, -0x51c, 0x54aca118)
    TEST_LD_W(0x909e34d2, 0xd37c0, -0x534, -0x534, 0x909e34d2)
    TEST_LD_W(0xc4b1feb0, 0xd0cf8,  0x188,  0x188, 0xc4b1feb0)
    TEST_LD_W(0xcb6cd8c0, 0xd6db8,  0x250,  0x250, 0xcb6cd8c0)
    TEST_LD_W(0x66394aee, 0xd522c, -0x61c, -0x61c, 0x66394aee)
    TEST_LD_W(0x48d355e4, 0xd6b90,  0x4f0,  0x4f0, 0x48d355e4)
    TEST_LD_W(0x1bb40b48, 0xd2e6c, -0x698, -0x698, 0x1bb40b48)
    TEST_LD_W(0x2a748b22, 0xd7160, -0x710, -0x710, 0x2a748b22)
    TEST_LD_W(0xd5cfb394, 0xd7f00,  0x014,  0x014, 0xd5cfb394)
    TEST_LD_W(0x72445ce0, 0xd59e4, -0x6ec, -0x6ec, 0x72445ce0)
    TEST_LD_W(0xc01702ce, 0xd02d8,  0x7d4,  0x7d4, 0xc01702ce)
    TEST_LD_W(0xa616d1be, 0xd07f0,  0x0c4,  0x0c4, 0xa616d1be)
    TEST_LD_W(0xf1456d95, 0xd7754,  0x158,  0x158, 0xf1456d95)
    TEST_LD_W(0xb98a0778, 0xd1a74,  0x308,  0x308, 0xb98a0778)
    TEST_LD_W(0x76852c0e, 0xd788c,  0x0fc,  0x0fc, 0x76852c0e)
    TEST_LD_W(0x3a4e6338, 0xd0000, -0x158, -0x158, 0x3a4e6338)
    TEST_LD_W(0x8625f42c, 0xd0000, -0x040, -0x040, 0x8625f42c)
    TEST_LD_W(0x16240da0, 0xd0000, -0x03c, -0x03c, 0x16240da0)
    TEST_LD_W(0x325a52cc, 0xd0000,  0x110,  0x110, 0x325a52cc)
    TEST_LD_W(0x848cbadf, 0xd0000,  0x028,  0x028, 0x848cbadf)
    TEST_LD_W(0x95696380, 0xd0000, -0x1e0, -0x1e0, 0x95696380)
    TEST_LD_W(0xcf5f7ec0, 0xd0000, -0x274, -0x274, 0xcf5f7ec0)
    TEST_LD_W(0x82ae70d0, 0xd0000,  0x224,  0x224, 0x82ae70d0)
    TEST_LD_W(0xc354a660, 0xd0000,  0x6f0,  0x6f0, 0xc354a660)
    TEST_LD_W(0x66a38db4, 0xd0000,  0x230,  0x230, 0x66a38db4)
    TEST_LD_W(0x13649030, 0xd0000,  0x5c4,  0x5c4, 0x13649030)
    TEST_LD_W(0xb7f66e24, 0xd0000,  0x2b0,  0x2b0, 0xb7f66e24)
    TEST_LD_W(0xc268a414, 0xd0000,  0x5c0,  0x5c0, 0xc268a414)
    TEST_LD_W(0x102044e3, 0xd0000,  0x30c,  0x30c, 0x102044e3)
    TEST_LD_W(0xff0f205f, 0xd0000,  0x7e0,  0x7e0, 0xff0f205f)
    TEST_LD_W(0xe394e882, 0xd0000,  0x300,  0x300, 0xe394e882)
    TEST_LD_W(0x6b53ef5a, 0xd0000,  0x3d0,  0x3d0, 0x6b53ef5a)
    TEST_LD_W(0xd3ad5b32, 0xd0000, -0x290, -0x290, 0xd3ad5b32)
    TEST_LD_W(0x0e61fb40, 0xd0000, -0x71c, -0x71c, 0x0e61fb40)
    TEST_LD_W(0xcb58118c, 0xd0000, -0x5d0, -0x5d0, 0xcb58118c)
    TEST_LD_W(0xe56fb3a8, 0xd0000,  0x7ec,  0x7ec, 0xe56fb3a8)
    TEST_LD_W(0x6661617c, 0xd0000,  0x450,  0x450, 0x6661617c)
    TEST_LD_W(0x5f7c08b0, 0xd0000, -0x7dc, -0x7dc, 0x5f7c08b0)
    TEST_LD_W(0x2b1ea090, 0xd0000,  0x000,  0x000, 0x2b1ea090)
    TEST_LD_W(0xe4a9ee00, 0xd0000,  0x000,  0x000, 0xe4a9ee00)
    TEST_LD_W(0x6472d096, 0xd0000,  0x000,  0x000, 0x6472d096)
    TEST_LD_W(0xc60dfd1c, 0xd0000,  0x000,  0x000, 0xc60dfd1c)
    TEST_LD_W(0xaaa54652, 0xd0000,  0x000,  0x000, 0xaaa54652)
    TEST_LD_W(0xfd47929c, 0xd0000,  0x000,  0x000, 0xfd47929c)
    TEST_LD_W(0xe40e0b9e, 0xd0000,  0x000,  0x000, 0xe40e0b9e)
    TEST_LD_W(0x6bcb55b4, 0xd0000,  0x000,  0x000, 0x6bcb55b4)
    TEST_LD_W(0xe6cb2590, 0xd0000,  0x000,  0x000, 0xe6cb2590)
    TEST_LD_W(0x3d911cb8, 0xd0000,  0x000,  0x000, 0x3d911cb8)
    TEST_LD_W(0xe65874bd, 0xd0000,  0x000,  0x000, 0xe65874bd)
    TEST_LD_W(0x3a3c9edc, 0xd0000,  0x000,  0x000, 0x3a3c9edc)
    TEST_LD_W(0xbddd406e, 0xd0000,  0x000,  0x000, 0xbddd406e)
    TEST_LD_W(0xfe6fb690, 0xd0000,  0x000,  0x000, 0xfe6fb690)
    TEST_LD_W(0x941bc8b2, 0xd0000,  0x000,  0x000, 0x941bc8b2)
    TEST_LD_W(0x9393289c, 0xd0000,  0x000,  0x000, 0x9393289c)
    TEST_LD_W(0x29b2c02d, 0xd0000,  0x000,  0x000, 0x29b2c02d)
    TEST_LD_W(0x00000000, 0xd0000,  0x000,  0x000, 0x00000000)
###detect exception
    bne s2, zero, inst_error
    nop
###score ++
    addi.w s3, s3, 1
###output (s0<<24)|s3
inst_error:  
    slli.w t1, s0, 24
    NOP4
    or t0, t1, s3 
    NOP4
    st.w t0, s1, 0
    jirl zero, ra, 0
    nop
END(n14_ld_w_test)
